package durose.system.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import durose.system.mapper.Sys_menuMapper;
import durose.system.pojo.Sys_menu;
import durose.system.pojo.Sys_menuExample;
import durose.system.service.Sys_menuService;

@Service
public class Sys_menuServiceImpl implements Sys_menuService {
	@Autowired
	Sys_menuMapper mapper;
	
	@Override
	public int sys_menuAdd(Sys_menu pojo) {
		return mapper.insert(pojo);
	}

	@Override
	public void sys_menuDelete(int id) {
		mapper.deleteByPrimaryKey(id);
	}

	@Override
	public void sys_menuUpdate(Sys_menu pojo) {
		mapper.updateByPrimaryKey(pojo);
	}

	@Override
	public Sys_menu sys_menuGet(int id) {
		return mapper.selectByPrimaryKey(id);
	}

	@Override
	public List<Sys_menu> sys_menuList(String queryName) {
		Sys_menuExample example = new Sys_menuExample();
		example.createCriteria().andMenu_nameLike('%'+queryName+'%');
		return mapper.selectByExample(example);
	}

	@Override
	public List<Sys_menu> sys_menuParentList(int  parentId) {
		Sys_menuExample example = new Sys_menuExample();
		example.createCriteria().andMenu_parentEqualTo(parentId);
		return mapper.selectByExample(example);
	}
}
